def f(n):
    nq = int(n**0.5)
    ans = 1
    for i in xrange(2, nq + 1):
        if n % i == 0:
            ans += i
            j = n / i
            if i < j:
                ans += j
    return ans

isa = [0 for i in xrange(28124)]
a = []
for i in xrange(2, 28124):
    count = f(i)
    if count > i:
        a.append(i)

n = len(a)
for i in xrange(n):
    for j in xrange(n):
        b = a[i] + a[j]
        if b < 28124:
            isa[b] = 1

ans = 0
for i in xrange(28124):
    if not isa[i]:
        ans += i

print ans



